/*
 * @Author: yumao 123456
 * @Date: 2025-08-20 15:58:49
 * @LastEditors: yumao 123456
 * @LastEditTime: 2025-09-01 16:55:35
 * @FilePath: \龙飞\src\api\operatorCheck.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import request from '@/utils/request'
import { downloadPDF } from '@/utils/util'

const modelApi = {
  ApprovalByMe: '/modelApi/applyApprovalByMe',
  ApprovalToMe: '/modelApi/approvalToMe',
  ApprovalDetail: '/modelApi/approvalDetail',
  Approval: '/modelApi/approval',
  InvokePDF: '/modelApi/invokePDF',
  ModelInput: '/modelApi/modelInput',
  ScoreCardModelCalculate: '/modelApi/scoreCardModelCalculate',
}

export function applyApprovalByMe(parameter) {
  return request({
    url: modelApi.ApprovalByMe,
    method: 'get',
    params: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  })
}

export function approvalToMe(parameter) {
  return request({
    url: modelApi.ApprovalToMe,
    method: 'get',
    params: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  })
}

export function approvalDetail(parameter) {
  return request({
    url: modelApi.ApprovalDetail,
    method: 'get',
    params: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  })
}

export function approval(parameter) {
  return request({
    url: modelApi.Approval,
    method: 'post',
    data: parameter,
    formData: true,
  })
}

export function invokePDF(parameter) {
  return request({
    url: modelApi.InvokePDF,
    method: 'get',
    params: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  })
}

export function modelInput(parameter) {
  return request({
    url: modelApi.ModelInput,
    method: 'get',
    params: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  })
}

export function scoreCardModelCalculate(parameter) {
  return request({
    url: modelApi.ScoreCardModelCalculate,
    method: 'get',
    params: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
    },
  })
}

/**
 * 下载PDF文档
 * @param {Object} params 请求参数 (如 modelUuid, version)
 * @param {Object} options 配置选项
 * @returns {Promise} 下载Promise
 */
export function downloadModelPDF(params = {}, options = {}) {
  return downloadPDF(request, modelApi.InvokePDF, params, {
    defaultFileName: 'model-document.pdf',
    timeout: 30000,
    ...options,
  })
}
